import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jly.App;
import com.jly.controller.dto.UserDTO;
import com.jly.entity.User;
import com.jly.mapper.userMapper;
import com.jly.service.IUserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Collections;
import java.util.List;

@SpringBootTest(classes = App.class)
public class test {
    @Autowired
    private userMapper userMapper;
    @Autowired
    private IUserService userService;

    @Test
    public void selectPage(){
        // 使用内置插件 + XML配置
//        List<User> users = userMapper.selectByPage(Page.of(0, 5));
//        users.forEach(System.out::println);
        // 链式调用
/*        Page<User> userPage = userMapper.selectPage(Page.of(0, 5), new QueryWrapper<>());
//        userPage.getRecords().forEach(System.out::println);
        long pages = userPage.getPages();
        System.out.println(userPage.getTotal());*/
    }
    @Test
    public void test1(){
        Page<User> page = new Page<>(1, 5);
        Page<User> search = userService.search("%%", "%%","%%", 1, 5);
//        search.getRecords().forEach(System.out::println);
        System.out.println(search.getTotal());


    }

}
